//
//  DiaryTableViewCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "DiaryTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation DiaryTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews
{
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10 * WID, 5 * HEI , 120 * WID, 90 * HEI)];
    self.imageV.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.imageV];

    
    self.imageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageV.frame.size.height - 20 * HEI, self.imageV.frame.size.width, 20 * HEI)];
    [self.imageV addSubview:self.imageLabel];
    self.imageLabel.backgroundColor = [UIColor colorWithWhite:0.247 alpha:0.5];

    
    self.titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(self.imageV.frame.origin.x + self.imageV.frame.size.width + 10 * HEI, self.imageV.frame.origin.y + 5 * HEI, WIDTH - 160 * WID, 10 * HEI)];
    [self.contentView addSubview:self.titleLabel];

    
    self.dLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 15 * HEI, self.titleLabel.frame.size.width, 30 * HEI)];
    
    [self.contentView addSubview:self.dLabel];

    
    
}

-(void)setDiaryModel:(DiaryModel *)diaryModel{
    if (_diaryModel != diaryModel) {

        _diaryModel = diaryModel;
    }
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:self.diaryModel.image_url] placeholderImage:[UIImage imageNamed:@"loading.jpg"]];
    
    self.imageLabel.text = [NSString stringWithFormat:@"%@ 篇游记",self.diaryModel.attraction_trips_count];
    self.imageLabel.font = [UIFont systemFontOfSize:12];
    self.imageLabel.textAlignment = NSTextAlignmentCenter;
    self.imageLabel.textColor = [UIColor whiteColor];
    
    self.titleLabel.text = self.diaryModel.name;
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    
    self.dLabel.text = self.diaryModel.placeDescription;
    self.dLabel.font = [UIFont systemFontOfSize:12];
    self.dLabel.numberOfLines = 0;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
